/**
 * 复制
 */
var copyText = (content, callback) => {
    // 是否降级使用
    const isFallback = !navigator.clipboard;
    let eleTextarea = document.querySelector('#tempTextarea');
    if (!eleTextarea && isFallback) {
        eleTextarea = document.createElement('textarea');
        eleTextarea.style.width = 0;
        eleTextarea.style.position = 'fixed';
        eleTextarea.style.left = '-999px';
        eleTextarea.style.top = '10px';
        document.body.appendChild(eleTextarea);
    }
    const funCopy = function (text) {
        callback = callback || function () { };
        if (!isFallback) {
            navigator.clipboard.writeText(text).then(() => {
                callback();
            });
            return;
        }
        else {
            eleTextarea.value = text;
            eleTextarea.select();
            document.execCommand('copy', true);
            callback();
        }
    };
    funCopy(content);
};

export { copyText as default };
